/*
 * @Author: 熊燕萍
 * @Date: 2021-02-04 11:45:38
 * @LastEditors: 熊燕萍
 * @LastEditTime: 2021-02-23 11:04:27
 * @Description: file content
 * @FilePath: \ys.oltest\src\ys\map\control.js
 */
import {defaults as defaultControls, OverviewMap} from 'ol/control';// eslint-disable-line
import TileLayer from 'ol/layer/Tile'
import XYZ from "ol/source/XYZ";


function Control(map) {
    this.map = map;
}

/**
 * @description: 鹰眼功能
 * @return {*}
 */
Control.prototype.addOverviewMapControl = function () {
    const webKey = 'fe40e8bfa4d16f7a68afafe70ad0483e';
    const imgLayerUrl_dt = 'http://t{0-7}.tianditu.gov.cn/DataServer?T=img_c&X={x}&Y={y}&L={z}&tk='; //影像底图
    const imgLayerUrl_zj = 'http://t{0-7}.tianditu.gov.cn/DataServer?T=cia_c&X={x}&Y={y}&L={z}&tk='; //影像注记
    const layerDt = new TileLayer({
        source: new XYZ({
            url: imgLayerUrl_dt + webKey,
            wrapX: false,
            projection: 'EPSG:4326'
        })
    });
    const Tianditu_cva = new TileLayer({
        title: "天地图矢量注记图层",
        source: new XYZ({
            url: imgLayerUrl_zj + webKey,//webKey为天地图密钥
            wrapX: false
        })
    });
    var overviewMapControl = new OverviewMap({
        //加载鹰眼控件中显示的图层,默认是天地图
        layers: [layerDt, Tianditu_cva],
        //鹰眼控件一开始为展开方式
        collapsed: false,
        //鹰眼控件的样式名称
        className: 'ol-overviewmap myOverview'
    });
    this.map.addControl(overviewMapControl);
}


export default Control
